<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <search ref='search' :config='searchConfig' @getHeight='getHeight' @search='search' />
    <!-- table区域-begin -->
    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        v-bind='vexConfig'
        :align='left'
        :border='true'
        :checkbox-config="checkboxConfig"
        :columns='columns'
        :data='dataSource'
        :height='pageHeight-seachHeight-90'
        :loading='loading'
        :resizable='true'
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        :showOverflow='true'
        :toolbar-config='tableToolbar'
        size='mini'
        @checkbox-change='selectChangeEvent'
        @checkbox-all='selectChangeEvent'
      >
        <template #toolbar_buttons>
          <div class='table-operator'>
            <a-button v-has="'targetService:add'" type="primary" @click="handleAdd">新增</a-button>
            <a-button v-has="'targetService:edit'" tabindex="primary" @click="batchDel">删除</a-button>
            <a-button v-has="'targetService:export'" type="primary" @click="downExportXls('sfaVisitTarget_service')">导出</a-button>
          </div>
        </template>
        <template #detail='{ row }'>
          <a @click='handleDetail(row)'>{{ row.custCode }}</a>
        </template>
        <template #status='{ row }'>
          <a-switch :checked='row.status' size='small' @change='handleStatus(row,$event)' />
        </template>
        <template #action='{ row:record }'>
         <!-- <a  @click='handleEdit(record)'>编辑</a>
          <a-divider type='vertical' /> -->
          <a href='javascript:' @click='handleBusiness("经销商目标管理",record)'>日志</a>
        </template>
        <template #pager>
          <vxe-pager
            :currentPage.sync='ipagination.current'
            :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
            :page-size.sync='ipagination.pageSize'
            :pageSizes='ipagination.pageSizeOptions'
            :total='ipagination.total'
            @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <sfa-visit-service-provider-modal ref="modalForm" @ok="modalFormOk"></sfa-visit-service-provider-modal>
    <business-log ref='businessLog'></business-log>
  </a-card>
</template>

<script>
import SfaVisitServiceProviderModal from './modules/SfaVisitServiceProviderModal'
import { PageListMixin } from '@/mixins/PageListMixin'

export default {
  name: "经销商目标管理",
  mixins:[PageListMixin],
  components: {
    SfaVisitServiceProviderModal,
  },
  data () {
    return {
      //查询区域
      searchConfig:[
        {
          type: 'input',
          name: 'custCode',
          placeholder: '经销商编码'
        },
        {
          type: 'input',
          name: 'custName',
          placeholder: '经销商名称'
        },
        // {
        //   type: 'input',
        //   name: 'positionName',
        //   placeholder: '职位名称'
        // },
        {
          type: 'date-month',
          name: 'month',
          placeholder: '目标年月'
        },
        // {
        //   type: 'tree-select',
        //   name: 'orgCode',
        //   placeholder: '所属组织',
        //   dataType:'org',
        // },
      ],
      // 表头
      columns: [
        { type: 'checkbox', width: 50, fixed: 'left' },
        {
          title: '经销商编码',
          minWidth:150,
          field: 'custCode',
          slots: { default: 'detail'}
        },
        {
          title: '经销商名称',
          minWidth:80,
          field: 'custName'
        },
        // {
        //   title: '职位名称',
        //   minWidth:80,
        //   field: 'positionName'
        // },
        {
          title: '所属组织',
          minWidth:80,
          field: 'departName'
        },
        {
          title: '目标年月',
          minWidth:80,
          field: 'month'
        },
        {
          title: '巡店目标次数',
          minWidth:120,
          field: 'shopTargetCount'
        },
        {
          title: '培训目标次数',
          minWidth:120,
          field: 'trainTargetCount'
        },
        {
          title: '形象覆盖次数',
          minWidth:120,
          field: 'imageCoverCount'
        },
        {
          title: 'S',
          minWidth:120,
          field: 'coverCounts'
        },
        {
          title: 'A',
          minWidth:120,
          field: 'coverCounta'
        },
        {
          title: 'B',
          minWidth:120,
          field: 'coverCountb'
        },
        {
          title: 'C',
          minWidth:120,
          field: 'coverCountc'
        },
        {
          title: 'D',
          minWidth:120,
          field: 'coverCountd'
        },
        {
          title: '创建人',
          align: 'left',
          minWidth: 80,
          field: 'createName'
        },
        {
          title: '创建时间',
          minWidth: 140,
          field: 'createTime'
        },
        {
          title: '更新人',
          align: 'left',
          minWidth: 80,
          field: 'updateName'
        },
        {
          title: '更新时间',
          align: 'left',
          minWidth: 80,
          field: 'updateTime'
        },
        {
          title: '操作',
          field: 'action',
          fixed: 'right',
          width: 120,
          slots: { default: 'action' }
        }
      ],
      isorter: {
        permflag: 'servuce_provider_page_impl'
      },
      url: {
        list: window._CONFIG['domianSfaURL'] + "/visit/sfaVisitTarget/findPageList",
        // exportXlsUrl: window._CONFIG['domianSfaURL'] + "/sfaVisitSummaryService/todoExcel",
        detail: window._CONFIG['domianSfaURL'] + "/visit/sfaVisitTarget/getInfo",
        deleteBatch: window._CONFIG['domianSfaURL'] + "/visit/sfaVisitTarget/deleteBatch",
      },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>